package com.yzmoney.wechat.service;

import com.yzmoney.common.constant.Constants;
import com.yzmoney.common.constant.PropertyUtils;
import com.yzmoney.common.util.HttpClientUtils;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 发送客服消息/模板消息
 *
 * @author DOVE
 */
@Component
public class WeChatQRCodeService {
    private static Logger logger = Logger.getLogger(WeChatQRCodeService.class);

    //https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKEN
    private static String QECode_URL = PropertyUtils.getValue("QECodeUrl", "",
            Constants.GZH_PATH);

    @Autowired
    private WechatAccessTokenService wechatAccessTokenService;

    public String getQRCodeInfo(String param) {
        String url = QECode_URL + wechatAccessTokenService.getGZHAccessToken();
        String result = HttpClientUtils.post(url, param);
        logger.info(Constants.LOGPRIFIX + "url=" + url + ",result=" + result);
        return result;
    }
}
